#pragma once
#include <iostream>
#include <pthread.h>
#include <string>
#include <cstdio>
typedef void*(*func_t)(void*);

class threadData
{
public:
    void* args_;
    std::string name_;
};

class Thread
{
public:
    Thread(int num,func_t callback,void * args)
        :func_(callback)
    {
        char namebuf[64];
        snprintf(namebuf,sizeof namebuf,"thread - %d",num);
        name_ = namebuf;
        tdata_.name_ = name_;
        tdata_.args_ = args;
    }
    void start()
    {
        pthread_create(&tid_,nullptr,func_,(void*)&tdata_);
    }
    void join()
    {
        pthread_join(tid_,nullptr);
    }
    std::string name()
    {
        return tdata_.name_;
    }
    ~Thread()
    {

    }


private:
    pthread_t tid_;
    threadData tdata_;
    std::string name_;
    func_t func_;
};